using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace InvestmentIntelligence.DbModel.Models.Mapping
{
    public class CorporateEventMap : EntityTypeConfiguration<CorporateEvent>
    {
        public CorporateEventMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.CorporateActionType)
                .IsRequired()
                .HasMaxLength(100);

            this.Property(t => t.CurrentDividendCurrency)
                .HasMaxLength(20);

            this.Property(t => t.Frequency)
                .HasMaxLength(30);

            // Table & Column Mappings
            this.ToTable("CorporateEvent", "TradingData");
            this.Property(t => t.CorporateActionId).HasColumnName("CorporateActionId");
            this.Property(t => t.SecurityId).HasColumnName("SecurityId");
            this.Property(t => t.Date).HasColumnName("Date");
            this.Property(t => t.CorporateActionType).HasColumnName("CorporateActionType");
            this.Property(t => t.DeclarationDate).HasColumnName("DeclarationDate");
            this.Property(t => t.ExDate).HasColumnName("ExDate");
            this.Property(t => t.PayDate).HasColumnName("PayDate");
            this.Property(t => t.RecordDate).HasColumnName("RecordDate");
            this.Property(t => t.AdjustmentFactor).HasColumnName("AdjustmentFactor");
            this.Property(t => t.GrossDividend).HasColumnName("GrossDividend");
            this.Property(t => t.CurrentDividendCurrency).HasColumnName("CurrentDividendCurrency");
            this.Property(t => t.Frequency).HasColumnName("Frequency");
            this.Property(t => t.Id).HasColumnName("Id");
        }
    }
}
